layui.use(['element', 'form', 'layedit', 'laydate', 'laypage', 'layer', 'upload'], function() {
    var form = layui.form,
        layer = layui.layer,
        layedit = layui.layedit,
        laydate = layui.laydate,
        form2 = layui.form,
        upload = layui.upload;
    var laypage = layui.laypage,
        layer = layui.layer;


    form.on('select(trademark)', function(data){
        $("#brand").empty()
        $("#model").empty()
        var id = data.value
        $.ajax({
            type:"post",
            url:"trademarkOrbrand",
            data:{trademark:id},
            dataType: 'json',
            success:function(result){
                if(result.msg == "车系查询成功" && result.data!= null){
                    var trademarkparam = "<option value=''></option>";
                    for(var i = 0 ; i < result.data != null &&i < result.data.length  ; i++ ){
                        trademarkparam += "<option value='"+result.data[i].name+"'>"+result.data[i].name+"</option>";
                    }
                    $("#brand").append(trademarkparam)//强制险
                    layui.form.render("select");
                }
            }
        })
    })

    form.on('select(brand)', function(data){
        $("#model").empty()
        var id = data.value
        $.ajax({
            type:"post",
            url:"trademarkOrbrand",
            data:{trademark:$("#trademark :selected").val(),brand:id,model:"select"},
            dataType: 'json',
            success:function(result){
                if(result.msg == "车型查询成功" && result.data!= null) {
                    var trademarkparam = "<option value=''></option>";
                    for (var i = 0; i < result.data != null && i < result.data.length; i++) {
                        trademarkparam += "<option value='" + result.data[i].name + "'>" + result.data[i].name + "</option>";
                    }
                    $("#model").append(trademarkparam)//强制险
                    layui.form.render("select");
                }
            }
        })
    })


    $.ajax({
        type:"post",
        url:"trademarkOrbrand",
        data:{},
        dataType: 'json',
        success:function(result){
            if(result.msg == "品牌查询成功" && result.data!= null){
                var trademarkparam = "<option value=''></option>";
                for(var i = 0 ; i <result.data != null &&i < result.data.length  ; i++ ){
                    trademarkparam += "<option value='"+result.data[i].name+"'>"+result.data[i].name+"</option>";
                }
                $("#trademark").append(trademarkparam)//强制险
                layui.form.render("select");
            }
        }
    })
})